package com.candy.listener;

import javax.servlet.ServletContextAttributeEvent;
import javax.servlet.ServletContextAttributeListener;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

@WebListener
public class ApplicationLinstener implements ServletContextListener, ServletContextAttributeListener {
    @Override
    public void contextInitialized(ServletContextEvent sce) {
        System.out.println("ServlectContext(application)创建");
    }

    @Override
    public void contextDestroyed(ServletContextEvent sce) {
        System.out.println("ServlectContext(application)销毁");
    }

    @Override
    public void attributeAdded(ServletContextAttributeEvent event) {
        System.out.println("已监听到application作用域中数据新增，"+event.getName()+";"+event.getValue());
    }

    @Override
    public void attributeRemoved(ServletContextAttributeEvent event) {
        System.out.println("已监听到application作用域中数据移除，"+event.getName()+";"+event.getValue());
    }

    @Override
    public void attributeReplaced(ServletContextAttributeEvent event) {
        System.out.println("已监听到application作用域中数据更新，"+event.getName()+";"+event.getValue());
    }
}
